﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RestaurateurConsole
{
    public partial class NewAccountActivity : Form
    {
        private bool cancelled = false;
        public NewAccountActivity()
        {
            InitializeComponent();
            tableLayoutPanel1.Controls.Add(new RadioButton() { Text = "Purchase", Checked = false });
            tableLayoutPanel1.Controls.Add(new RadioButton() { Text = "Payment", Checked = true });
            tableLayoutPanel1.Controls.Add(new Label() { Text = "Date:" });
            tableLayoutPanel1.Controls.Add(new DateTimePicker() { Value = DateTime.Now });
            tableLayoutPanel1.Controls.Add(new Label() { Text = "Account:" });
            tableLayoutPanel1.Controls.Add(new TextBox());
            tableLayoutPanel1.Controls.Add(new Label() { Text = "Amount:" });
            tableLayoutPanel1.Controls.Add(new TextBox());
            tableLayoutPanel1.Controls.Add(new Label() { Text = "Bill No:" });
            tableLayoutPanel1.Controls.Add(new TextBox());
            tableLayoutPanel1.Controls.Add(new Button() { Text = "OK", Width = tableLayoutPanel1.Controls[5].Width });
            tableLayoutPanel1.Controls.Add(new Button() { Text = "Cancel", Width = tableLayoutPanel1.Controls[5].Width });

            (tableLayoutPanel1.Controls[10] as Button).Click += new EventHandler(Okay);
            (tableLayoutPanel1.Controls[11] as Button).Click += new EventHandler(Cancel);

            this.AcceptButton = tableLayoutPanel1.Controls[10] as Button;
            this.CancelButton = tableLayoutPanel1.Controls[11] as Button;
        }

        void Cancel(object sender, EventArgs e)
        {
            cancelled = true;
            this.Close();
        }

        void Okay(object sender, EventArgs e)
        {
            if ((tableLayoutPanel1.Controls[5] as TextBox).Text == "")
            {
                MessageBox.Show("Please enter the name of the account.");
                return;
            }
            if ((tableLayoutPanel1.Controls[7] as TextBox).Text == "")
            {
                MessageBox.Show("Please enter the amount.");
                return;
            }
            this.Close();
        }

        public bool IsCancelled
        {
            get
            {
                return cancelled;
            }
        }

        public string BillNo
        {
            get
            {
                return (tableLayoutPanel1.Controls[9] as TextBox).Text;
            }
        }

        public bool IsPayment
        {
            get
            {
                return (tableLayoutPanel1.Controls[1] as RadioButton).Checked;
            }
        }

        public DateTime DatePicked
        {
            get
            {
                return (tableLayoutPanel1.Controls[3] as DateTimePicker).Value;
            }
        }

        public string UserName
        {
            get
            {
                return (tableLayoutPanel1.Controls[5] as TextBox).Text;
            }
            set
            {
                (tableLayoutPanel1.Controls[5] as TextBox).Text = value;
            }
        }

        public string Amount
        {
            get
            {
                return (tableLayoutPanel1.Controls[7] as TextBox).Text;
            }
        }
    }
}
